package pers.cj.pdos.service;

import org.apache.ibatis.annotations.Param;
import pers.cj.pdos.entity.Goods;
import pers.cj.pdos.entity.GoodsStock;
import com.baomidou.mybatisplus.extension.service.IService;
import pers.cj.pdos.vo.GoodsVo;
import pers.cj.pdos.vo.HouseQueryDetailVo;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务类
 * </p>
 *
 * @author chenj
 * @since 2019-11-04
 */
public interface IGoodsStockService extends IService<GoodsStock> {
    GoodsStock getByGoodsAndHouse(String goodsId,String houseId);
    long countByGoods(String goodsId);
    List<GoodsStock> listByGoods(String goodsId);

    /**
     * 根据仓库id和list中的goodsId来获取商品库存表
     * @param houseId
     * @param list
     * @return
     */
    List<GoodsStock> listByHouseAndGoodsList(String houseId,List list);


    List<Map> listByHouseAndGoodsMap(String houseId,Map map);

    Map<String, Long> checkByGoodsList(List<Goods> goodsList);

    boolean checkByGoods(String goodsId);

    List<GoodsVo> listVo(String companyId, Integer page, Integer limit, String goodsTypeId, Integer goodsStatus, Boolean filterZero, String search,String storeId,String houseId);

    long count(String companyId,String goodsTypeId, Integer goodsStatus, Boolean filterZero, String search,String storeId,String houseId);


    List<GoodsVo> listVoByGoodsIds(List<String> goodsIds, String storeId, String houseId);

    /**
     * 获取库存总额
     * @return
     */
    BigDecimal getTotalStockAmount(String companyId, String storeId,String houseId);

    /**
     * 获取库存总额最高的商品机器库存总额
     * @return
     */
    Map getHighestStockAmountWithGoods(String companyId, String storeId, String houseId);

    /**
     * 获取库存金额 按商品排序
     * @return
     */
    List<Map> getAmountOrderByGoods(String companyId, String storeId, String houseId);

    /**
     * 获取库存金额 按门店排序
     * @return
     */
    List<Map> getAmountOrderByStore(String companyId, String storeId, String houseId);

    /**
     * 获取库存金额 按仓库排序
     * @return
     */
    List<Map> getAmountOrderByHouse(String companyId, String storeId, String houseId);


    /**
     * 获取库存数量 按仓库排序
     * @return
     */
    List<Map> getNumberOrderByHouse(String companyId, String storeId, String houseId);

    /**
     * 获取库存查询的详情
     * @param page
     * @param limit
     * @param goodsId
     * @return
     */
    List<HouseQueryDetailVo> listDetailListByGoods(Integer page, Integer limit, String goodsId, String search,
                                                   String storeId,
                                                   String houseId);
    /**
     * 获取库存查询的详情的个数
     * @param goodsId
     * @return
     */
    Long countDetailListByGoods(String goodsId, String search,
                                String storeId,
                                String houseId);

    /**
     * 根据仓库分组取得该商品的库存数量
     * @param goodsId
     * @param storeId
     * @param houseId
     * @return
     */
    List<Map> getGoodsStockGroupByHouse(String companyId, String goodsId, String storeId, String houseId);
}
